package com.yz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yz.entity.Readroom;
import com.yz.entity.dto.ReadroomDto;
import com.yz.service.ReadroomService;
import com.yz.util.Result;

@RestController
public class ReadroomController {
	@Autowired
	private ReadroomService readroomService;
	
	@RequestMapping("/getReadList")
	public Object getReadList(ReadroomDto readroomDto,Readroom readroom) {
		List<Readroom> list = readroomService.getRead(readroomDto);
		readroomDto.setPage(null);
		readroomDto.setLimit(null);
		List<Readroom> list2 = readroomService.getRead(readroomDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addRead")
	public Object addRead(Readroom readroom) {
		if(readroomService.addRead(readroom)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	@RequestMapping("/updateRead")
	public Object updateRead(Readroom readroom) {
		if(readroomService.updateRead(readroom)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delRead")
	public Object delRead(int rid) {
		if(readroomService.delRead(rid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
}
